(function(angular) {
	'use strict';
	angular.module('fs.waf').controller('cda.popup.documentViewController', controller);
	controller.$inject = [ '$scope', '$q', '$uibModalInstance', 'Constants', 'dialogsModule', 'gridService', 'modalService', 'layoutConfig', 'validatorConfig',
			'authService', 'commonService', 'documentService' ];
	function controller($scope, $q, $uibModalInstance, Constants, dialogsModule, gridService, modalService, layoutConfig, validatorConfig, authService, commonService, documentService) {
		var ctrl = this, params = $scope.$stateParams.params, log = $scope.loggerFactory.getLogger("documentPopup"), dialogParams;
		ctrl.dialogsModule = dialogsModule;
		ctrl.layoutConfig = layoutConfig;
		dialogParams = dialogsModule.params;
		ctrl.close = function() {
			if (!dialogsModule.btnCallback || !dialogsModule.btnCallback['close'] || dialogsModule.btnCallback['close']() !== false) {
				$uibModalInstance.dismiss();
			}
		};
		ctrl.init = function() {
			documentService.initDropDownDataOptions(ctrl).then(function() {
				documentService.initDocMimeTypeOptions(ctrl).then(function() {
					ctrl.document = angular.copy(dialogParams);
					ctrl.document.uploadObj = [angular.copy(dialogParams)];
				});
			});
		};
	}
})(angular);